//
//  CountScrollView.m
//  FruitVIP
//
//  Created by 孙艳玲 on 15/6/30.
//  Copyright (c) 2015年 孙艳玲. All rights reserved.
//

#import "CountScrollView.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation CountScrollView

- (instancetype)initWithFrame:(CGRect)frame :(NSString *)moneyText
{
    self = [super initWithFrame:frame];
    if (self) {
        [self getUI:moneyText ];
    }
    return self;
}

- (void)getUI:(NSString *)moneyText
{
    self.firstSelected = NO;
    self.secondSelected = NO;
    self.thirdSelected = NO;
    self.couponsSelected = NO;
    
    UIView *friutView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH/2.9)];
//    friutView.backgroundColor = [UIColor redColor];
    [self addSubview:friutView];
    
    UIImageView *fruitImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH/4, SCREEN_WIDTH/4.5)];
    fruitImageView.backgroundColor = [UIColor yellowColor];
    fruitImageView.userInteractionEnabled = YES;
    UIImage *fruitImage = [UIImage imageNamed:@"detailtwo.jpg"];
    fruitImageView.image = fruitImage;
    [friutView addSubview:fruitImageView];
    
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH  - 10 - SCREEN_WIDTH/3, fruitImageView.frame.origin.y, SCREEN_WIDTH/3, fruitImageView.frame.size.height/4)];
    nameLabel.text = @"台湾密风铃莲雾";
    nameLabel.font = [UIFont systemFontOfSize:15];
    nameLabel.textAlignment = NSTextAlignmentRight;
//    nameLabel.backgroundColor = [UIColor redColor];
    [friutView addSubview:nameLabel];
    
    UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(nameLabel.frame.origin.x, nameLabel.frame.origin.y + nameLabel.frame.size.height + 5, nameLabel.frame.size.width, nameLabel.frame.size.height)];
    NSString *str = @"￥";
    priceLabel.text = @"13.00";
    priceLabel.text = [str stringByAppendingString:priceLabel.text];
    priceLabel.font = [UIFont systemFontOfSize:15];
   priceLabel.textAlignment = NSTextAlignmentRight;
    [friutView addSubview:priceLabel];
    
    
    UILabel *countLabel = [[UILabel alloc] initWithFrame:CGRectMake(priceLabel.frame.origin.x, priceLabel.frame.origin.y + priceLabel.frame.size.height + 5, priceLabel.frame.size.width - 15, priceLabel.frame.size.height)];
    countLabel.text = @"购买数量";
    countLabel.font = [UIFont systemFontOfSize:15];
    countLabel.textAlignment = NSTextAlignmentRight;
    [friutView addSubview:countLabel];
    
    UILabel *detailCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(countLabel.frame.origin.x + countLabel.frame.size.width, countLabel.frame.origin.y, 15, countLabel.frame.size.height)];
    detailCountLabel.text = @"1";
    detailCountLabel.font = [UIFont systemFontOfSize:15];
    detailCountLabel.textAlignment = NSTextAlignmentRight;
    [friutView addSubview:detailCountLabel];
    
    
    UILabel *firstLine = [[UILabel alloc] initWithFrame:CGRectMake(0, fruitImageView.frame.origin.y + fruitImageView.frame.size.height + 30, SCREEN_WIDTH, 1)];
    firstLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [friutView addSubview:firstLine];
    
    UIView *friutSecondView = [[UIView alloc] initWithFrame:CGRectMake(0, friutView.frame.origin.y + friutView.frame.size.height, SCREEN_WIDTH,  friutView.frame.size.height)];
    //    friutView.backgroundColor = [UIColor redColor];
    [self addSubview:friutSecondView];
    
    UIImageView *fruitSecondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH/4, SCREEN_WIDTH/4.5)];
    fruitSecondImageView.backgroundColor = [UIColor yellowColor];
    fruitSecondImageView.userInteractionEnabled = YES;
    fruitSecondImageView.image = fruitImage;
    [friutSecondView addSubview:fruitSecondImageView];
    
    UILabel *nameSecondLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH  - 10 - SCREEN_WIDTH/3, fruitSecondImageView.frame.origin.y, SCREEN_WIDTH/3, fruitSecondImageView.frame.size.height/4)];
    nameSecondLabel.text = @"台湾密风铃莲雾";
    nameSecondLabel.font = [UIFont systemFontOfSize:15];
    nameSecondLabel.textAlignment = NSTextAlignmentRight;
    //    nameLabel.backgroundColor = [UIColor redColor];
    [friutSecondView addSubview:nameSecondLabel];
    
    UILabel *priceSecondLabel = [[UILabel alloc]initWithFrame:CGRectMake(nameSecondLabel.frame.origin.x, nameSecondLabel.frame.origin.y + nameSecondLabel.frame.size.height + 5, nameSecondLabel.frame.size.width, nameSecondLabel.frame.size.height)];
    priceSecondLabel.text = @"13.00";
    priceSecondLabel.text = [str stringByAppendingString:priceSecondLabel.text];
    priceSecondLabel.font = [UIFont systemFontOfSize:15];
    priceSecondLabel.textAlignment = NSTextAlignmentRight;
    [friutSecondView addSubview:priceSecondLabel];
    
    
    UILabel *countSecondLabel = [[UILabel alloc] initWithFrame:CGRectMake(priceSecondLabel.frame.origin.x, priceSecondLabel.frame.origin.y + priceSecondLabel.frame.size.height + 5, priceSecondLabel.frame.size.width - 15, priceSecondLabel.frame.size.height)];
    countSecondLabel.text = @"购买数量";
    countSecondLabel.font = [UIFont systemFontOfSize:15];
    countSecondLabel.textAlignment = NSTextAlignmentRight;
    [friutSecondView addSubview:countSecondLabel];
    
    UILabel *detailCountSecondLabel = [[UILabel alloc] initWithFrame:CGRectMake(countSecondLabel.frame.origin.x + countSecondLabel.frame.size.width, countSecondLabel.frame.origin.y, 15, countSecondLabel.frame.size.height)];
    detailCountSecondLabel.text = @"1";
    detailCountSecondLabel.font = [UIFont systemFontOfSize:15];
    detailCountSecondLabel.textAlignment = NSTextAlignmentRight;
    [friutSecondView addSubview:detailCountSecondLabel];
    
    
    UILabel *secondViewLine = [[UILabel alloc] initWithFrame:CGRectMake(0, fruitImageView.frame.origin.y + fruitImageView.frame.size.height + 30, SCREEN_WIDTH, 1)];
    secondViewLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [friutSecondView addSubview:secondViewLine];
    
 
    UIView *friutThirdView = [[UIView alloc] initWithFrame:CGRectMake(0, friutSecondView.frame.origin.y + friutSecondView.frame.size.height, SCREEN_WIDTH,  friutView.frame.size.height)];
    //    friutView.backgroundColor = [UIColor redColor];
    [self addSubview:friutThirdView];
    
    UIImageView *fruitThirdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH/4, SCREEN_WIDTH/4.5)];
    fruitThirdImageView.backgroundColor = [UIColor yellowColor];
    fruitThirdImageView.userInteractionEnabled = YES;
    fruitThirdImageView.image = fruitImage;
    [friutThirdView addSubview:fruitThirdImageView];
    
    UILabel *nameThirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH  - 10 - SCREEN_WIDTH/3, fruitThirdImageView.frame.origin.y, SCREEN_WIDTH/3, fruitThirdImageView.frame.size.height/4)];
    nameThirdLabel.text = @"台湾密风铃莲雾";
    nameThirdLabel.font = [UIFont systemFontOfSize:15];
    nameThirdLabel.textAlignment = NSTextAlignmentRight;
    //    nameLabel.backgroundColor = [UIColor redColor];
    [friutThirdView addSubview:nameThirdLabel];
    
    UILabel *priceThirdLabel = [[UILabel alloc]initWithFrame:CGRectMake(nameThirdLabel.frame.origin.x, nameThirdLabel.frame.origin.y + nameThirdLabel.frame.size.height + 5, nameThirdLabel.frame.size.width, nameThirdLabel.frame.size.height)];
    priceThirdLabel.text = @"13.00";
    priceThirdLabel.text = [str stringByAppendingString:priceThirdLabel.text];
    priceThirdLabel.font = [UIFont systemFontOfSize:15];
    priceThirdLabel.textAlignment = NSTextAlignmentRight;
    [friutSecondView addSubview:priceThirdLabel];
    
    
    UILabel *countThirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(priceThirdLabel.frame.origin.x, priceThirdLabel.frame.origin.y + priceThirdLabel.frame.size.height + 5, priceThirdLabel.frame.size.width - 15, priceThirdLabel.frame.size.height)];
    countThirdLabel.text = @"购买数量";
    countThirdLabel.font = [UIFont systemFontOfSize:15];
    countThirdLabel.textAlignment = NSTextAlignmentRight;
    [friutThirdView addSubview:countSecondLabel];
    
    UILabel *detailCountThirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(countThirdLabel.frame.origin.x + countThirdLabel.frame.size.width, countThirdLabel.frame.origin.y, 15, countThirdLabel.frame.size.height)];
    detailCountThirdLabel.text = @"1";
    detailCountThirdLabel.font = [UIFont systemFontOfSize:15];
    detailCountThirdLabel.textAlignment = NSTextAlignmentRight;
    [friutThirdView addSubview:detailCountThirdLabel];
    
    
    UILabel *thirdViewLine = [[UILabel alloc] initWithFrame:CGRectMake(0, fruitImageView.frame.origin.y + fruitImageView.frame.size.height + 30, SCREEN_WIDTH, 1)];
    thirdViewLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [friutThirdView addSubview:thirdViewLine];

    
    UIView *fourthView = [[UIView alloc] initWithFrame:CGRectMake(0, friutThirdView.frame.origin.y + friutThirdView.frame.size.height + 5, SCREEN_WIDTH, SCREEN_HEIGHT/15)];
//    fourthView.backgroundColor = [UIColor yellowColor];
    [self addSubview:fourthView];
  
    UILabel *payCount = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH/3, fourthView.frame.size.height)];
    payCount.text = @"数量";
    [fourthView addSubview:payCount];
    
    UILabel *payCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 20 - SCREEN_WIDTH/10, 0, SCREEN_WIDTH/10, payCount.frame.size.height)];
    payCountLabel.text = @"5";
    [fourthView addSubview:payCountLabel];
    
    UILabel *fourthLine = [[UILabel alloc] initWithFrame:CGRectMake(10, payCount.frame.origin.y + payCount.frame.size.height + 5, SCREEN_WIDTH - 20, 1)];
    fourthLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [fourthView addSubview:fourthLine];
    
    
    UIView *fifthView = [[UIView alloc] initWithFrame:CGRectMake(0, fourthView.frame.origin.y + fourthView.frame.size.height + 5, SCREEN_WIDTH, fourthView.frame.size.height)];
//    fifthView.backgroundColor = [UIColor yellowColor];
    [self addSubview:fifthView];
    
    UILabel *payMoney = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH/3, fifthView.frame.size.height)];
    payMoney.text = @"总金额";
    payMoney.font = [UIFont systemFontOfSize:15];
    [fifthView addSubview:payMoney];
    
    
    UILabel *payMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 20 - SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, fifthView.frame.size.height)];
    payMoneyLabel.text = @"0";
    payMoneyLabel.text = [str stringByAppendingString:payMoneyLabel.text];
    payMoneyLabel.textAlignment = NSTextAlignmentRight;
    [fifthView addSubview:payMoneyLabel];
    
    UILabel *fifthLine = [[UILabel alloc] initWithFrame:CGRectMake(10, payMoneyLabel.frame.origin.y + payMoneyLabel.frame.size.height + 5, SCREEN_WIDTH - 20, 1)];
    fifthLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [fifthView addSubview:fifthLine];
    
    UILabel *select = [[UILabel alloc] initWithFrame:CGRectMake(10, friutView.frame.size.height * 3 + 30 + fourthView.frame.size.height + fifthView.frame.size.height, SCREEN_WIDTH - 20, fruitImageView.frame.size.height/3)];
    select.text = @"选择支付方式";
    select.font = [UIFont systemFontOfSize:20];
    [self addSubview:select];
  
    
    
    UIImageView *firstImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, select.frame.origin.y + select.frame.size.height + 10, SCREEN_WIDTH , SCREEN_WIDTH/4)];
    firstImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *firstTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(firstTapAction)];
    [firstImageView addGestureRecognizer:firstTap];
    [self addSubview:firstImageView];
    
    
    
    UIImageView *weChatImaheView = [[UIImageView alloc] initWithFrame:CGRectMake(select.frame.origin.x, 10, SCREEN_WIDTH/5, firstImageView.frame.size.height - 20)];
//    weChatImaheView.backgroundColor = [UIColor lightGrayColor];
    weChatImaheView.contentMode = UIViewContentModeScaleAspectFit;
    weChatImaheView.userInteractionEnabled = YES;
    UIImage *weChatImage = [UIImage imageNamed:@"wechart.png"];
    weChatImaheView.image = weChatImage;
    [firstImageView addSubview:weChatImaheView];

    
    UILabel *weChatLabel = [[UILabel alloc] initWithFrame:CGRectMake(weChatImaheView.frame.origin.x + weChatImaheView.frame.size.width + 10, weChatImaheView.frame.size.height/3, SCREEN_WIDTH/2, weChatImaheView.frame.size.height/3)];
    weChatLabel.text = @"微信支付";
    weChatLabel.font = [UIFont systemFontOfSize:17];
    [firstImageView addSubview:weChatLabel];
    
    
    UILabel *weChatDetail = [[UILabel alloc] initWithFrame:CGRectMake(weChatLabel.frame.origin.x, weChatLabel.frame.origin.y + weChatLabel.frame.size.height + 3, weChatLabel.frame.size.width, weChatLabel.frame.size.height)];
    weChatDetail.text = @"推荐微信用户使用";
    weChatDetail.font = [UIFont systemFontOfSize:13];
    weChatDetail.textColor = [UIColor lightGrayColor];
    [firstImageView addSubview:weChatDetail];
    
    
    self.firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.firstButton.frame = CGRectMake(weChatLabel.frame.origin.x + weChatLabel.frame.size.width + 25, weChatImaheView.frame.origin.y + weChatImaheView.frame.size.height/3, 25, 25);
//    firstButton.backgroundColor = [UIColor redColor];
    self.firstButton.layer.cornerRadius = CGRectGetHeight([self.firstButton bounds])/2;
   //边框颜色
    [self.firstButton.layer setBorderWidth:1.0];
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 230/255.0, 230/255.0, 230/255.0, 1});
    [self.firstButton.layer setBorderColor:colorref];
    [self.firstButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
    [self.firstButton addTarget:self action:@selector(firstButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [firstImageView addSubview:self.firstButton];
    
    
    
    UIImageView *secondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, firstImageView.frame.origin.y + firstImageView.frame.size.height, firstImageView.frame.size.width, firstImageView.frame.size.height)];
//    secondImageView.backgroundColor = [UIColor greenColor];
    secondImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *secondTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(secondTapAction)];
    [secondImageView addGestureRecognizer:secondTap];
    [self addSubview:secondImageView];
    
    
    UIImageView *payImageView = [[UIImageView alloc] initWithFrame:CGRectMake(weChatImaheView.frame.origin.x, 10, weChatImaheView.frame.size.width , weChatImaheView.frame.size.height)];
//    payImageView.backgroundColor = [UIColor lightGrayColor];
//    payImageView.contentMode = UIViewContentModeScaleAspectFit;
    payImageView.userInteractionEnabled = YES;
    UIImage *payImage = [UIImage imageNamed:@"zhifubao.png"];
    payImageView.image = payImage;
    [secondImageView addSubview:payImageView];
    
    
    UILabel *payLabel = [[UILabel alloc] initWithFrame:CGRectMake(weChatLabel.frame.origin.x, payImageView.frame.size.height/3, weChatLabel.frame.size.width, weChatLabel.frame.size.height)];
    payLabel.text = @"支付宝";
    payLabel.font = [UIFont systemFontOfSize:17];
    [secondImageView addSubview:payLabel];
    
    UILabel *payDetail = [[UILabel alloc] initWithFrame:CGRectMake(payLabel.frame.origin.x, payLabel.frame.origin.y + payLabel.frame.size.height + 3, payLabel.frame.size.width, payLabel.frame.size.height)];
    payDetail.text = @"推荐支付宝用户使用";
    payDetail.font = [UIFont systemFontOfSize:13];
    payDetail.textColor = [UIColor lightGrayColor];
    [secondImageView addSubview:payDetail];
    
    
    self.secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.secondButton.frame = CGRectMake(self.firstButton.frame.origin.x, payImageView.frame.origin.y + payImageView.frame.size.height/3, 25, 25);
//    secondButton.backgroundColor = [UIColor redColor];
    self.secondButton.layer.cornerRadius = CGRectGetHeight([self.secondButton bounds])/2;
    //边框颜色
    [self.secondButton.layer setBorderWidth:1.0];
    [self.secondButton.layer setBorderColor:colorref];
    [self.secondButton addTarget:self action:@selector(secondButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [secondImageView addSubview:self.secondButton];
    
    
    UIImageView *thirdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, secondImageView.frame.origin.y + secondImageView.frame.size.height, secondImageView.frame.size.width, secondImageView.frame.size.height)];
//    thirdImageView.backgroundColor = [UIColor purpleColor];
    thirdImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *thirdTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(thirdTapAction)];
    [thirdImageView addGestureRecognizer:thirdTap];
    [self addSubview:thirdImageView];
    
    
    UIImageView *fastImageView = [[UIImageView alloc] initWithFrame:CGRectMake(payImageView.frame.origin.x, 10, payImageView.frame.size.width, payImageView.frame.size.height)];
//    fastImageView.backgroundColor = [UIColor lightGrayColor];
    fastImageView.userInteractionEnabled = YES;
    UIImage *fastImage = [UIImage imageNamed:@"pay.png"];
    fastImageView.image = fastImage;
    [thirdImageView addSubview:fastImageView];
    
    
    UILabel *fastLabel = [[UILabel alloc] initWithFrame:CGRectMake(payLabel.frame.origin.x, fastImageView.frame.size.height/3, payLabel.frame.size.width, payLabel.frame.size.height)];
    fastLabel.text = @"快钱支付";
    fastLabel.font = [UIFont systemFontOfSize:17];
    [thirdImageView addSubview:fastLabel];
    
    UILabel *fastDetail = [[UILabel alloc] initWithFrame:CGRectMake(fastLabel.frame.origin.x, fastLabel.frame.origin.y + fastLabel.frame.size.height + 3, fastLabel.frame.size.width, fastLabel.frame.size.height)];
    fastDetail.text = @"推荐快钱用户使用";
    fastDetail.font = [UIFont systemFontOfSize:13];
    fastDetail.textColor = [UIColor lightGrayColor];
    [thirdImageView addSubview:fastDetail];
    
    
    self.thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.thirdButton.frame = CGRectMake(self.secondButton.frame.origin.x, fastImageView.frame.origin.y + fastImageView.frame.size.height/3, 25, 25);
//    thirdButton.backgroundColor = [UIColor redColor];
    self.thirdButton.layer.cornerRadius = CGRectGetHeight([self.thirdButton bounds])/2;
    //边框颜色
    [self.thirdButton.layer setBorderWidth:1.0];
//    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
//    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 230/255.0, 230/255.0, 230/255.0, 1});
    [self.thirdButton.layer setBorderColor:colorref];
    [self.thirdButton addTarget:self action:@selector(thirdButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [thirdImageView addSubview:self.thirdButton];
    
    
    UILabel *secondLine = [[UILabel alloc] initWithFrame:CGRectMake(10, thirdImageView.frame.origin.y + thirdImageView.frame.size.height + 10, SCREEN_WIDTH - 20, 1)];
    secondLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [self addSubview:secondLine];
    
    UIImageView *fouthImageView = [[UIImageView alloc] initWithFrame:CGRectMake(secondLine.frame.origin.x, secondLine.frame.origin.y + secondLine.frame.size.height + 5, SCREEN_WIDTH - 20, SCREEN_HEIGHT/15)];
//    fouthImageView.backgroundColor = [UIColor yellowColor];
    fouthImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *fouthTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fouthTapAction)];
    [fouthImageView addGestureRecognizer:fouthTap];
    [self addSubview:fouthImageView];
    
    UILabel *countYLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, fouthImageView.frame.size.width/3, fouthImageView.frame.size.height - 10)];
    countYLabel.text = @"使用优惠券";
    countYLabel.font = [UIFont systemFontOfSize:20];
//    countLabel.backgroundColor = [UIColor redColor];
    [fouthImageView addSubview:countYLabel];
    
    
    UIButton *countButton = [UIButton buttonWithType:UIButtonTypeCustom];
    countButton.frame = CGRectMake(countYLabel.frame.origin.x + countYLabel.frame.size.width + 5, countYLabel.frame.origin.y + 2.5, 2 * countYLabel.frame.size.width/3, countYLabel.frame.size.height - 5);
    [countButton setTitle:@"5张可用" forState:UIControlStateNormal];
    [countButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    countButton.titleLabel.font = [UIFont systemFontOfSize:15];
    countButton.layer.cornerRadius = CGRectGetHeight([countButton bounds])/2;
    countButton.backgroundColor = [UIColor redColor];
    [fouthImageView addSubview:countButton];
    
    UIButton *selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    selectButton.frame = CGRectMake(fouthImageView.frame.size.width - 30, fouthImageView.frame.size.height/3 , 15, 10);
    [selectButton setImage:[UIImage imageNamed:@"countButton.png"] forState:UIControlStateNormal];
    [selectButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [selectButton addTarget:self action:@selector(selectButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [fouthImageView addSubview:selectButton];
    
    self.thirdLine = [[UILabel alloc] initWithFrame:CGRectMake(10, fouthImageView.frame.origin.y  + fouthImageView.frame.size.height , SCREEN_WIDTH - 20, 1)];
    self.thirdLine.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1];
    [self addSubview:self.thirdLine];

    
        
    
    
    self.detailPayLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.thirdLine.frame.origin.x, self.thirdLine.frame.origin.y + self.thirdLine.frame.size.height + 30, SCREEN_WIDTH / 4, 25)];
    self.detailPayLabel.text = @"提货信息";
    self.detailPayLabel.font= [UIFont systemFontOfSize:18];
    [self addSubview:self.detailPayLabel];
    

    self.goodsLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.detailPayLabel.frame.origin.x, self.detailPayLabel.frame.origin.y + self.detailPayLabel.frame.size.height + 10, self.detailPayLabel.frame.size.width, self.detailPayLabel.frame.size.height)];
    self.goodsLabel.text = @"提货人:";
    self.goodsLabel.textColor = [UIColor lightGrayColor];
    self.goodsLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.goodsLabel];
    
    self.nameText = [[UITextField alloc] initWithFrame:CGRectMake(self.goodsLabel.frame.origin.x + self.goodsLabel.frame.size.width + 10, self.goodsLabel.frame.origin.y, SCREEN_WIDTH/2, self.goodsLabel.frame.size.height)];
    self.nameText.layer.cornerRadius = CGRectGetHeight([self.nameText bounds])/4;
    
    //边框颜色
    [self.nameText.layer setBorderWidth:1.0];
    [self.nameText.layer setBorderColor:colorref];
    self.nameText.font = [UIFont systemFontOfSize:15];
    
    [self addSubview:self.nameText];
    
   self.takePay = [[UILabel alloc] initWithFrame:CGRectMake(self.goodsLabel.frame.origin.x, self.goodsLabel.frame.origin.y + self.goodsLabel.frame.size.height +10, self.goodsLabel.frame.size.width, self.goodsLabel.frame.size.height)];
    self.takePay.text = @"手 机:";
    self.takePay.textColor = [UIColor lightGrayColor];
    self.takePay.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.takePay];
    
    
    self.phoneText = [[UITextField alloc] initWithFrame:CGRectMake(self.takePay.frame.origin.x + self.takePay.frame.size.width + 10, self.takePay.frame.origin.y, self.nameText.frame.size.width, self.takePay.frame.size.height)];
    self.phoneText.font = [UIFont systemFontOfSize:15];
    self.phoneText.layer.cornerRadius = CGRectGetHeight([self.phoneText bounds])/4;
    
    //边框颜色
    [self.phoneText.layer setBorderWidth:1.0];
    [self.phoneText.layer setBorderColor:colorref];
    [self addSubview:self.phoneText];
    
    
    
    
    self.addLable = [[UILabel alloc] initWithFrame:CGRectMake(self.takePay.frame.origin.x, self.takePay.frame.origin.y + self.takePay.frame.size.height + 10, self.takePay.frame.size.width, self.takePay.frame.size.height)];
    self.addLable.text = @"提货点:";
    self.addLable.font = [UIFont systemFontOfSize:15];
    self.addLable.textColor = [UIColor lightGrayColor];
    [self addSubview:self.addLable];
    
       UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
    addButton.frame = CGRectMake(self.addLable.frame.origin.x + self.addLable.frame.size.width + 10, self.addLable.frame.origin.y, self.phoneText.frame.size.width, self.addLable.frame.size.height);
    [addButton addTarget:self action:@selector(addButtonAction) forControlEvents:UIControlEventTouchUpInside];
    addButton.layer.cornerRadius = CGRectGetHeight([addButton bounds])/4;
    //边框颜色
    [addButton.layer setBorderWidth:1.0];
    [addButton.layer setBorderColor:colorref];
    [self addSubview:addButton];
    
    
    self.allPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2.5,addButton.frame.origin.y + addButton.frame.size.height + 30, SCREEN_WIDTH/4.5, SCREEN_WIDTH/9)];
    self.allPriceLabel.text = @"总金额：";
    self.allPriceLabel.font = [UIFont systemFontOfSize:17];
    //            priceLabel.backgroundColor = [UIColor yellowColor];
    [self addSubview:self.allPriceLabel];
    
    self.symbolLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.allPriceLabel.frame.origin.x + self.allPriceLabel.frame.size.width, self.allPriceLabel.frame.origin.y, 15, self.allPriceLabel.frame.size.height)];
    self.symbolLabel.text = @"￥";
    self.symbolLabel.font = [UIFont systemFontOfSize:17];
    [self addSubview:self.symbolLabel];
    
    
   self.allMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.symbolLabel.frame.origin.x + self.symbolLabel.frame.size.width, self.symbolLabel.frame.origin.y - 10, SCREEN_WIDTH - self.allPriceLabel.frame.size.width - 15, self.symbolLabel.frame.size.height + 10)];
    self.allMoneyLabel.text = moneyText;
    self.allMoneyLabel.font = [UIFont systemFontOfSize:25];
    //            allMoneyLabel.backgroundColor = [UIColor yellowColor];
    [self addSubview:self.allMoneyLabel];

    


    self.nameText.delegate = self;
    self.phoneText.delegate = self;
    
    self.contentSize = CGSizeMake(SCREEN_WIDTH,friutView.frame.size.height * 3 + fourthView.frame.size.height + fifthView.frame.size.height + select.frame.size.height + weChatImaheView.frame.size.height + payImageView.frame.size.height + fastImageView.frame.size.height + countYLabel.frame.size.height + self.detailPayLabel.frame.size.height + self.goodsLabel.frame.size.height + self.takePay.frame.size.height + self.addLable.frame.size.height + 400);
}

//点击键盘return键触发的方法
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    //点击return取消第一响应者
    [self.nameText resignFirstResponder];
    [self.phoneText resignFirstResponder];
   
    return YES;
}

//点击空白处回收键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{
    
    [self.nameText resignFirstResponder];
    [self.phoneText resignFirstResponder];
    
    
}

- (void)firstButtonAction:(UIButton *)button
{
   
    if (self.firstSelected == NO) {
        self.firstSelected = YES;
        self.secondSelected = NO;
        self.thirdSelected = NO;
        [self.firstButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
        [self.secondButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        [self.thirdButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
    }
    else{
        
//     [self.firstButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];

         self.firstSelected = NO;
        

        
    }
}

- (void)secondButtonAction:(UIButton *)button
{
    
    if (self.secondSelected == NO) {
        self.secondSelected = YES;
        self.firstSelected = NO;
        self.thirdSelected = NO;
        [self.secondButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
        [self.firstButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        [self.thirdButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
    }
    else{
       
//        [self.secondButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];

        self.secondSelected = NO;

    }
   
}


- (void)thirdButtonAction:(UIButton *)button
{
    if (self.thirdSelected == NO) {
        self.thirdSelected = YES;
        self.secondSelected = NO;
        self.firstSelected = NO;
        [self.thirdButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
        [self.firstButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        [self.secondButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        
    }
    else{
        self.thirdSelected = NO;
//        [button setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
    }
   
}

- (void)fouthTapAction
{
    [self.selectButton selectCoupons];
    
}
- (void)selectButtonAction
{
     [self.selectButton selectCoupons];
}
- (void)secondTapAction
{
    if (self.secondSelected == NO) {
        self.secondSelected = YES;
        self.firstSelected = NO;
        self.thirdSelected = NO;
        [self.secondButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
        [self.firstButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        [self.thirdButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
    }
    else{
        self.secondSelected = NO;
        
    }
    NSLog(@"支付宝");

}
- (void)thirdTapAction
{
    if (self.thirdSelected == NO) {
        self.thirdSelected = YES;
        self.secondSelected = NO;
        self.firstSelected = NO;
        [self.thirdButton setImage:[UIImage imageNamed:@"danxuan.png"] forState:UIControlStateNormal];
        [self.firstButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        [self.secondButton setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
        
    }
    else{
        self.thirdSelected = NO;
        //        [button setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
    }

}

- (void)addButtonAction
{
    [self.takeAddDelegate takeAddress];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
